<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>watch & computed</title>
</head>
<body>
  <div id="app">{{name}}</div>
  <ul id="test">
    <li><p>11111111111</p></li>
    <li><div>22222222<span>12121</span></div></li>
    <li><span>3333333333</span></li>
    <li>4444444</li>
  </ul>
  <script src="/dist/umd/vue.js"></script>
  <script>
    // 事件委托 代替 循环列表添加事件
    window.onload = function() {
      const ul = document.querySelector('#test');
      ul.onclick = function(ev) {
        var ev = ev || window.event;
        var target = ev.target || ev.srcElement;
        while(target !== ul) {
          const nodeName = target.nodeName.toLowerCase()
          if(nodeName === 'li') {
            console.log(nodeName);
            break;
          }
          console.log('parentNode: ', nodeName, target.parentNode.nodeName.toLowerCase() );
          target = target.parentNode
        }
      }
    }
    const vm = new Vue({
      el: '#app',
      data() {
        return {
          name: 'zf',
          age: 10
        }
      },
    })
  </script>
</body>
</html>